using System;
using System.Collections;
using CommandLine.Utility;
using Slaks.Graphs.GraphBuilder;

namespace Vector2SvmConverter
{
	class Class1
	{
		[STAThread]
		static void Main(string[] args)
		{
			Arguments commandLine = new Arguments(args);

			string outputFileParam = "outputFile";
			string parsedFileListLabeledParam = "parsedFileListLabeled";
			string parsedFileListUnlabeledParam = "parsedFileListUnlabeled";
			string pruningParam = "pruning";
			string categoryFileParam = "categoryFile";
			string outputTrainingFileParam = "outputTrainingFileTemplate";
			string outputTestFileParam = "outputTestFileTemplate";
			string representationParam = "representation";

			string standardNormalizedRepresentation = "standardNormalized";
			string standardTFIDFRepresentation = "standardTFIDF";

      string termDocumentFrequencyPathParam = "termDocumentFrequencyPath";
			
			string outputFileValue = commandLine[outputFileParam];
			string parsedFileListLabeledValue = commandLine[parsedFileListLabeledParam];
			string parsedFileListUnlabeledValue = commandLine[parsedFileListUnlabeledParam];
			string categoryFileValue = commandLine[categoryFileParam];
			int pruning = int.Parse(commandLine[pruningParam]);
			string representationValue = commandLine[representationParam];
			string termDocumentFrequencyValue = commandLine[termDocumentFrequencyPathParam];

			BuilderType representation;
			if (representationValue == standardNormalizedRepresentation) representation = BuilderType.NormalizedFrequencyRepresentationSlaks;
			else if (representationValue == standardTFIDFRepresentation) representation = BuilderType.StandardTFIDFRepresentationSlaks;
			else throw new Exception("Representation unknown");

			string outputTrainingFileValue = commandLine[outputTrainingFileParam];
			string outputTestFileValue = commandLine[outputTestFileParam];

			Console.WriteLine("outputFile=" + outputFileValue);
			Console.WriteLine("parsedFileLabeledList=" + parsedFileListLabeledValue);
			Console.WriteLine("parsedFileUnlabeledList=" + parsedFileListUnlabeledValue);
			Console.WriteLine("categoryFile=" + categoryFileValue);
			Console.WriteLine("pruning=" + pruning);
			Console.WriteLine("representation=" + representation);
			Console.WriteLine("termDocumentFrequency=" + termDocumentFrequencyValue);
			Console.WriteLine("===============================================================================================");
			Console.WriteLine("outputTrainingFile="+outputTrainingFileValue);
			Console.WriteLine("outputTestFile="+outputTestFileValue);
			

			Converter converter = new Converter(outputFileValue,parsedFileListLabeledValue,parsedFileListUnlabeledValue,categoryFileValue,pruning,termDocumentFrequencyValue,representation);
			
			IList records = converter.Convert();


			string filenameTemplate = "-unknown";
			if (representation == BuilderType.NormalizedFrequencyRepresentationSlaks)
				filenameTemplate = "-normalized";
			else if (representation == BuilderType.StandardTFIDFRepresentationSlaks)
				filenameTemplate = "-tf-idf";

			//ShuffleTrainTest sh = new ShuffleTrainTest(records,outputTrainingFileValue,outputTestFileValue,filenameTemplate);
			//sh.ShuffleAndWrite();
		}
	}
}
